package com.cyufeng.blog.service.mapper;

import com.cyufeng.blog.dto.EmailDto;
import com.cyufeng.blog.entity.Email;

import java.util.ArrayList;
import java.util.List;
/**
 * 联系管理员
 * @author Cyufeng
 * Data:2018.12.30
 */
public class EmailMapper {
    public EmailDto entityTodto(Email email){
        EmailDto emailDto = new EmailDto();
        emailDto.setId(email.getId());
        emailDto.setTitle(email.getTitle());
        emailDto.setDetail(email.getDetail());
        emailDto.setDr(email.getDr());
        emailDto.setEmail(email.getEmail());
        emailDto.setMadeTime(email.getMadeTime());
        emailDto.setDelTime(email.getDelTime());
        return emailDto;
    }
    public Email dtoToentity(EmailDto emailDto){
        Email email = new Email();
        email.setId(emailDto.getId());
        email.setTitle(emailDto.getTitle());
        email.setDetail(emailDto.getDetail());
        email.setDr(emailDto.getDr());
        email.setEmail(emailDto.getEmail());
        email.setMadeTime(emailDto.getMadeTime());
        email.setDelTime(emailDto.getDelTime());
        return email;
    }
    //list集合
    public List<EmailDto> entityTodto(List<Email> emailList){
        List<EmailDto> emailDtoList = new ArrayList<>();
        for (int i = 0;i<emailList.size();i++){
            Email email = emailList.get(i);
            EmailDto emailDto = new EmailDto();
            emailDto.setId(email.getId());
            emailDto.setTitle(email.getTitle());
            emailDto.setDetail(email.getDetail());
            emailDto.setDr(email.getDr());
            emailDto.setEmail(email.getEmail());
            emailDto.setMadeTime(email.getMadeTime());
            emailDto.setDelTime(email.getDelTime());
            emailDtoList.add(emailDto);
        }

        return emailDtoList;
    }
    public List<Email> dtoToentity(List<EmailDto> emailDtoList){
        List<Email> emailList = new ArrayList<>();
        for (int i = 0;i<emailList.size();i++) {
            Email email = new Email();
            EmailDto emailDto = emailDtoList.get(i);
            email.setId(emailDto.getId());
            email.setTitle(emailDto.getTitle());
            email.setDetail(emailDto.getDetail());
            email.setDr(emailDto.getDr());
            email.setEmail(emailDto.getEmail());
            email.setMadeTime(emailDto.getMadeTime());
            email.setDelTime(emailDto.getDelTime());
            emailList.add(email);
        }
        return emailList;
    }
}
